package com.graduation.project.controller.grade;

import com.graduation.project.entity.dto.grade.GetThesisGradeDTO;
import com.graduation.project.entity.dto.grade.SaveOrUpdateGradeDTO;
import com.graduation.project.service.grade.GradeService;
import com.graduation.project.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/grade")
public class GradeController {

    @Autowired
    private GradeService gradeService;

    /**
     * 获取当前论文得分
     * @param input 获取论文成绩输入类
     * @return ResultUtil
     */
    @PreAuthorize("hasAnyAuthority('pro:finalize:grade')")
    @GetMapping("/get/getThesisGrade")
    public ResultUtil<?> getThesisGrade(GetThesisGradeDTO input) {
        return gradeService.getThesisGrade(input);
    }

    /**
     * 评分
     * @param input 评分输入类
     * @return ResultUtil
     */
    @PreAuthorize("hasAnyAuthority('pro:finalize:grade')")
    @PostMapping("/post/gradeThesis")
    public ResultUtil<?> gradeThesis(@RequestBody SaveOrUpdateGradeDTO input) {
        return gradeService.gradeThesis(input);
    }

    /**
     * 获取用户课题成绩信息
     * @return ResultUtil
     */
    @GetMapping("/get/getUserTaskScore")
    public ResultUtil<?> getUserTaskScore() {
        return gradeService.getUserTaskScore();
    }
}
